<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>each</title>
  <script src="js/jquery-1.11.3.js"></script>
</head>

<body>
  <ul>
    <li>亮亮</li>
    <li>然然</li>
    <li>东东</li>
    <li>涛涛</li>
  </ul>
  <script>
    //$(..).each()  与 $.each()区别
    $("ul>li").each(function (i) {
      console.log(`${$(this).html()} - 到!`);
    });

    $.each($("ul>li"), function (i, li) {
      console.log(`${$(li).html()} - 到`);
    });

    function add() {
      var sum = 0;

      // for (let i = 0; i < arguments.length; i++) {
      //    sum += arguments[i];
      // }
      $.each(arguments, function (i, n) {
        sum += n;
      });

      return sum;
    }
    console.log(add(1, 2, 3, 4, 5));

    var arr = ["亮亮", "然然", "东东"];
    $.each(arr, function (i, name) {
      console.log(`${i+1} - ${name} - 到`);

    });
  </script>
</body>

</html>